package com.factory.code.service.model;

import com.factory.code.common.VelocityTemplateText;
import com.factory.code.common.helper.StringHelper;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.io.File;
import java.util.Date;

/**
 * aaaa
 */
@Data
public class CodeContextModel {


    @VelocityTemplateText("表名 ")
    private String tableName;

    @VelocityTemplateText("作者名 CodeFactory")
    private String author;

    @VelocityTemplateText("包名 com.factory.code")
    private String packageName;

    @VelocityTemplateText("根据包名转文件路径 com\\factory\\code")
    private String packagePath;

    public String getPackagePath() {
        if (StringUtils.isEmpty(packageName)) {
            return "";
        }
        return packageName.replace(".", File.separator);
    }

    @VelocityTemplateText("类名 UserInfopackageName.replace(\".\", \"\\\\\")")
    private String beanName;


    @VelocityTemplateText("首字母小写 userInfo")
    private String beanNameLF;

    public String getBeanNameLF() {
        beanNameLF = StringHelper.lowerFirstLetter(beanName);
        return beanNameLF;
    }

    @VelocityTemplateText("时间 年月日 2021-08-04")
    private String dateFormat = DateFormatUtils.format(new Date(), "yyyy-MM-dd");

    @VelocityTemplateText("时间 时分秒 15:30:47")
    private String timeFormat = DateFormatUtils.format(new Date(), "HH:mm:ss");

    @VelocityTemplateText("时间 2021-08-04 15:30:47")
    private String dateTimeFormat = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");

}
